//
//  HMHotTableViewCell.m
//  HeartMark
//
//  Created by rimi on 16/11/8.
//  Copyright © 2016年 黄华强. All rights reserved.
//

#import "HMLATNoteCell.h"
#import <Masonry.h>

@interface HMLATNoteCell ()

@property(nonatomic,strong)UILabel *message;
@property(nonatomic,strong)UILabel *time;
@property(nonatomic,strong) UILabel *colltionNumLabel;
@end


@implementation HMLATNoteCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //初始化内部子视图
        [self addSubsViewWithContenView];
    }
    return  self;
}

-(void)addSubsViewWithContenView {
    //信息
    _message = [[UILabel alloc] initWithFrame:CGRectMake(12, 8, SCREEN_WIDTH - 24, 50)];
    _message.font = [UIFont systemFontOfSize:13];
    _message.numberOfLines = 2;
    [self.contentView addSubview:_message];
    
    //时间
    _time = [[UILabel alloc] initWithFrame:CGRectMake(100, 60, SCREEN_WIDTH - 112, 15)];
    _time.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:_time];
    
    UIImageView *collectionImageView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 60, 15, 15)];
    collectionImageView.image = [UIImage imageNamed:@"收藏_16"];
    [self.contentView addSubview:collectionImageView];
    
    _colltionNumLabel = [[UILabel alloc] initWithFrame:CGRectMake(32, 60, 70, 15)];
    _colltionNumLabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:_colltionNumLabel];
}


#pragma mark - 重写setter方法

- (void)setModel:(HMLATNoteModel *)model {
    _model = model;
    NSString *content = [_model.noteMessage stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    _message.text = content;
    NSString *nameStr = _model.noteName;
    if ([nameStr isEqualToString:@""]) {
        nameStr = @"匿名用户";
    }
    
    
    NSString *timeStr = [NSString stringWithFormat:@"%@---%@",nameStr,_model.noteTime];
    _time.text = timeStr;
    _time.textAlignment = NSTextAlignmentRight;
    AVObject *obj = _model.object;
    _colltionNumLabel.text = [NSString stringWithFormat:@"%@", obj[@"collectNumber"]];
}


@end
